package com.cw.carwashserve.service.impl;

import com.cw.carwashserve.domain.Services;
import com.cw.carwashserve.mapper.ServiceMapper;
import com.cw.carwashserve.service.ServiceService;
import com.ruoyi.common.core.context.SecurityContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ServiceServiceImpl implements ServiceService {

    @Autowired
    private ServiceMapper serviceMapper;

    @Override
    public List<Services> selectServiceList(Services service) {
        return serviceMapper.selectServiceList(service);
    }

    @Override
    public Services selectServiceById(Long id) {
        return serviceMapper.selectServiceById(id);
    }

    @Override
    public int insertService(Services service) {
        service.setCreatedBy(SecurityContextHolder.getUserId());
        service.setCreatedAt(new Date());
        return serviceMapper.insertService(service);
    }

    @Override
    public int updateService(Services service) {
        service.setUpdatedBy(SecurityContextHolder.getUserId());
        service.setUpdatedAt(new Date());
        return serviceMapper.updateService(service);
    }

    @Override
    public int deleteServiceById(Long id) {
        return serviceMapper.deleteServiceById(id);
    }

    @Override
    public int deleteServiceByIds(Long[] ids) {
        return serviceMapper.deleteServiceByIds(ids);
    }
}
